package com.inthecheesefactory.lab.designlibrary;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;


import java.util.ArrayList;
import java.util.List;

/**
 * Created by FZT on 2016/3/14.
 */
public class GameJudgeIntroduceFragment extends LinearLayout {
    private View view;

    public GameJudgeIntroduceFragment(Context context) {
        super(context);
        init(context, null, 0);
    }

    public GameJudgeIntroduceFragment(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs, 0);
    }

    public GameJudgeIntroduceFragment(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, attrs, defStyle);
    }

    public void init(Context context,AttributeSet attributeSet,int def){
        view=LinearLayout.inflate(context,R.layout.game_judge_introduce_fragment,this);
        initView();
        addData(context);
    }

    private RecyclerView rvJudgeIntroduce;
    private List<GameJudgeModel> gameJudgeModels;
    public void initView(){
        gameJudgeModels=new ArrayList<>();
        rvJudgeIntroduce = (RecyclerView) view.findViewById(R.id.rv_judge_introduce);
    }
    public void addData(Context context){
        String [] names={"Tom Jou 尼古拉斯凯奇","Tom Jou 尼古拉斯凯奇","Tom Jou 尼古拉斯凯奇","Tom Jou 尼古拉斯凯奇","Tom Jou 尼古拉斯凯奇"};
        String [] countrys={"中国北京","中国南京","澳大利亚","澳大利亚","澳大利亚"};
        String [] jobs={"全犬种裁判","全犬种裁判","全犬种裁判","全犬种裁判","全犬种裁判"};
        int [] ids={R.drawable.ic_game_judge1,R.drawable.ic_game_judge2,R.drawable.ic_game_judge3,R.drawable.ic_game_judge3,R.drawable.ic_game_judge3};
        for(int i=0; i<5;i++){
            GameJudgeModel gameJudgeModel=new GameJudgeModel();
            gameJudgeModel.setName(names[i]);
            gameJudgeModel.setCountry(countrys[i]);
            gameJudgeModel.setJob(jobs[i]);
            gameJudgeModel.setImageId(ids[i]);
            gameJudgeModels.add(gameJudgeModel);
        }
        rvJudgeIntroduce.setLayoutManager(new LinearLayoutManager(context));
        rvJudgeIntroduce.addItemDecoration(new ItemDiver(context,R.drawable.bg_diver));
        GameJudgeReclerViewAdapter gameJudgeReclerViewAdapter=new GameJudgeReclerViewAdapter(gameJudgeModels);
        rvJudgeIntroduce.setAdapter(gameJudgeReclerViewAdapter);
    }

}
